import { Routes, Route } from "react-router-dom";
import Home from "@/pages/Home";
import Shop from "@/pages/Shop";

import About from "@/pages/About";
import Contact from "@/pages/Contact";
import ProductDetail from "@/pages/ProductDetail";
import Cart from "@/pages/Cart";
import Payment from "@/pages/Payment";
import User from "@/pages/User";
import Login from "@/pages/Login";
import Register from "@/pages/Register";
import OrderDetail from "@/pages/OrderDetail";
import { useState } from "react";
import { AuthContext } from '@/contexts/authContext';
import { LanguageProvider } from '@/contexts/LanguageContext';
import { CartProvider } from '@/contexts/CartContext';
import { Empty } from '@/components/Empty';

export default function App() {
  const [user, setUser] = useState<any>(null);

  const login = (userData: any) => {
    setUser(userData);
  };

  const logout = () => {
    setUser(null);
  };

  const isAuthenticated = !!user;

  return (
    <LanguageProvider>
      <CartProvider>
      <AuthContext.Provider
        value={{ isAuthenticated, user, login, logout }}
      >
        <Routes>
          <Route path="/" element={<Home />} />
          <Route path="/shop" element={<Shop />} />


          <Route path="/about" element={<About />} />
          <Route path="/contact" element={<Contact />} />
      <Route path="/product/:id" element={<ProductDetail />} />
      <Route path="/cart" element={<Cart />} />
        <Route path="/payment" element={<Payment />} />
        <Route path="/user" element={<User />} />
        <Route path="/login" element={<Login />} />
         <Route path="/register" element={<Register />} />
         <Route path="/order/:id" element={<OrderDetail />} />
        <Route path="*" element={<Empty />} />
        </Routes>
      </AuthContext.Provider>
      </CartProvider>
    </LanguageProvider>
  );
}